from core.item import Item
from core.action import Action
from core.support import set_cutscene

class Clothespin(Item):
    def __init__(self):
        Item.__init__(self, "clothespin")    # do basic initialization for every item
        
        # build list of actions
        self.add_action(UnlockRefrigerator)
    
    def get_description(self):
            return "a safety pin"
        
    def get_image(self):
        return 'images/items/clothespin.jpg'

# define actions for this item

class UnlockRefrigerator(Action):
    def __init__(self):
        Action.__init__(self, "unlock_refrigerator")    # do basic initialization for every action
        self.isOpen = False
    
    # this method gets called when action executed.  can be overridden in subclass
    def do_action(self,game,room,request):
        room.isFrigeUnlocked = True
        self.isOpen = True
        set_cutscene("MacGyver successfully picks the refrigerator lock.")
        return
    
    # should this action be available to player?
    def is_enabled(self):
        return not self.isOpen
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Pick Refrigerator Lock"
    
    # if omitted in your action we return "post"
    def get_method(self):
        return "get"